package com.example.ayniu.treadmill;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.Toast;

import com.example.ayniu.treadmill.base.BaseActivity;

public class MyAddressActivity extends BaseActivity implements ListView.OnItemClickListener{

    private ListView lv_address;
    private BaseAdapter address_adapter;
    private ImageView img_turnback;
    private RelativeLayout layout_addaddress;
    private Button bt_add_address,bt_save_address;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_address);

        lv_address = (ListView) findViewById(R.id.lv_members);
        ShowListView();
        lv_address.setAdapter(address_adapter);
        lv_address.setOnItemClickListener(this);

        img_turnback = (ImageView)findViewById(R.id.imgaddress_turnback);
        img_turnback.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        layout_addaddress = (RelativeLayout) findViewById(R.id.layout_addaddress);

        bt_add_address = (Button) findViewById(R.id.bt_add_address);
        bt_save_address = (Button) findViewById(R.id.bt_save_address);
        bt_add_address.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                layout_addaddress.setVisibility(View.VISIBLE);
            }
        });
        bt_save_address.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                layout_addaddress.setVisibility(View.GONE);
                Toast.makeText(MyAddressActivity.this, "新地址添加成功", Toast.LENGTH_LONG).show();
            }
        });
    }

    public void ShowListView(){
        // 实现share的listView列表内容
        address_adapter = new BaseAdapter() {
            @Override
            public int getCount() {
                return 1;//
            }

            @Override
            public Object getItem(int position) {
                return null;
            }

            @Override
            public long getItemId(int position) {
                return position;
            }

            @Override
            public View getView(int position, View convertView, ViewGroup parent) {
                LayoutInflater nflater = LayoutInflater.from(MyAddressActivity.this);
                convertView = nflater.inflate(R.layout.layout_lv_address, null);//绑定制定layout文件
                //实例化layout中的控件
                return convertView;
            }
        };
    }

    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

    }
}
